package com.ego.product.vo.spu;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import com.ego.product.po.SkuInfo;
import com.ego.product.to.coupon.SkuReductionTo;
import lombok.Getter;
import lombok.Setter;

import java.math.BigDecimal;
import java.util.List;

/**
 * @program: ego
 * @description: 库存量单位，对应商品销售属性
 * @author: KamTang
 * @create: 2022-11-22 14:51
 **/
@Setter
@Getter
public class Sku {
    /**
     * 属性列表
     */
    private List<Attr> attr;
    /**
     * 销售属性 —— 标题
     */
    private String skuName;
    /**
     * 价格
     */
    private BigDecimal price;
    /**
     * 主标题
     */
    private String skuTitle;
    /**
     * 副标题
     */
    private String skuSubtitle;
    /**
     * 图片
     */
    private List<Image> images;
    /**
     * 笛卡尔积
     */
    private List<String> descar;
    /**
     * 满多少件
     */
    private int fullCount;
    /**
     * 打折
     */
    private BigDecimal discount;
    /**
     * 是否叠加优惠
     */
    private Integer countStatus;
    /**
     * 满多少元
     */
    private BigDecimal fullPrice;
    /**
     * 减多少元
     */
    private BigDecimal reducePrice;
    /**
     * 是否叠加优惠
     */
    private Integer priceStatus;
    /**
     * 会员价格
     */
    private List<MemberPriceVo> memberPriceVo;

    /**
     * 构造SkuReductionTo
     * @param skuInfo @see SkuInfoEntity
     * @return @see SkuReductionTo
     */
    public SkuReductionTo buildSkuReductionTo(SkuInfo skuInfo) {
        SkuReductionTo skuReductionTo = BeanUtil.copyProperties(this, SkuReductionTo.class);
        skuReductionTo.setSkuId(skuInfo.getSkuId());
        if (CollectionUtil.isNotEmpty(memberPriceVo)) {
            skuReductionTo.setMemberPriceVo(memberPriceVo);
        }
        return skuReductionTo;
    }
}
